package com.cyw.common.config.jackson.serializer;

import com.cyw.common.utils.MosaicUtils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;

/**
 * 手机号-马赛克序列化器
 *
 * @author: cyw
 * @CreateTime: 2021/4/1 20:02
 **/
public class MosaicPhoneSerializer extends StdSerializer<String> {

    private static final long serialVersionUID = -6588532444974315869L;

    public MosaicPhoneSerializer() {
        this(null);
    }

    public MosaicPhoneSerializer(Class<String> t) {
        super(t);
    }

    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider provider) throws IOException {

        gen.writeString(MosaicUtils.mosaic(value, 3, 3));
    }
}

    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    